package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingLevel;
import com.zzyl.entity.NursingPlan;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceImpl implements NursingLevelService {
    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    @Override
    public List<NursingLevelVo> getAllNursingLevel() {
        return nursingLevelMapper.getAllNursingLevel();
    }

    @Override
    public void insertNursingLevel(NursingLevelVo nursingLevelVo) {
        nursingLevelMapper.insertNursingLevel(nursingLevelVo);
    }

    @Override
    public PageResponse<NursingLevelVo> getByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<NursingLevel> nursingLevels = nursingLevelMapper.selectByPage(name, status);
        PageResponse<NursingLevelVo> levelVoPageResponse = PageResponse.of(nursingLevels, NursingLevelVo.class);
        return levelVoPageResponse;
    }

    @Override
    public NursingLevelVo getNursingLevelById(Long id) {
        return nursingLevelMapper.getNursingLevelById(id);
    }

    @Override
    public void updateNursingLevel(NursingLevelVo nursingLevelVo) {
        nursingLevelMapper.updateNursingLevel(nursingLevelVo);
        nursingLevelMapper.selNursingPlan(nursingLevelVo);
    }

    @Override
    public void deleteNursingLevel(Long id) {
        nursingLevelMapper.deleteNursingLevel(id);
    }

    @Override
    public void updateNursingLevelStatus(Long id, Integer status) {
        nursingLevelMapper.updateNursingLevelStatus(id, status);
    }
}
